﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace DataAccess
{
   public class Link
   {
       private static string BuildAbsolute(string relativeUrl)
       {
           Uri uri = HttpContext.Current.Request.Url;
           string app = HttpContext.Current.Request.ApplicationPath;
           if (!app.EndsWith("/"))
               app += "/";
           relativeUrl = relativeUrl.TrimStart('/');
           return HttpUtility.UrlPathEncode(string.Format("http://{0}:{1}{2}{3}", uri.Host, uri.Port, app, relativeUrl));
       }
       public static string ToDiaDiem(string id, string page)
       {
           if (page == "1")
               return BuildAbsolute(String.Format("DanhSachPhongTro.aspx?IDDiaDiem={0}", id));
           else
               return BuildAbsolute(String.Format("DanhSachPhongTro.aspx?IDDiaDiem={0}&Page={1}", id, page));
       }
       public static string ToDiaDiem(string id)
       {
           return ToDiaDiem(id, "1");
       }
       public static string ToDanhSachDiaDiem(string id)
       {
           return BuildAbsolute(String.Format("ChiTietPhongTro.aspx?IDPhongTro={0}", id));
       }
       public static string ToHinhDanhSachDiaDiem(string fileName)
       {
           return BuildAbsolute(String.Format("HinhPhongTro/{0}", fileName));
       }
       public static string ToHinhBVk(string fileName)
       {
           return BuildAbsolute(String.Format("HinhBaiViet/{0}", fileName));
       }

      // bai viet
       public static string ToDanhSachDiaDiemB(string id)
       {
           return BuildAbsolute(String.Format("ChiTietBaiViet.aspx?MaBaiViet={0}", id));
       }
       public static string ToHinhDanhSachDiaDiemB(string fileName)
       {
           return BuildAbsolute(String.Format("HinhBaiViet/{0}", fileName));
       }
       //
       public static string ToDatPhong(string id)
       {
           return BuildAbsolute(String.Format("DatPhong.aspx?IDDanhSach={0}", id));
       }
       // hinh ca nhan
       public static string ToHinhCaNhan(string fileName)
       {
           return BuildAbsolute(String.Format("HinhUser/{0}", fileName));
       }
       // tim kiem

       public static string ToTimKiem(string timkiemString, string page)
       {
           if (page == "1")
               return BuildAbsolute(String.Format("TimKiem.aspx?StringText={0}", timkiemString));
           return BuildAbsolute(String.Format("TimKiem.aspx?StringText={0}&Page={1}", timkiemString, page));
       }
       public static string ToTimKiem(string timkiemString)
       {
           return ToTimKiem(timkiemString, "1");
       }

       //
       public static string ToDanhMucBaiViet(string page)
       {
           if (page == "1")
               return BuildAbsolute("DanhMucBaiViet.aspx");
           else
               return BuildAbsolute(String.Format("DanhSachBaiViet.aspx?Page={0}", page));
       }

       public static string ToDanhMucBaiViet()
       {
           return ToDanhMucBaiViet("1");
       }

       public static string ToDanhMucPhongTro(string page)
       {
           if (page == "1")
               return BuildAbsolute("DanhMucPhongTro.aspx");
           else
               return BuildAbsolute(String.Format("DanhSachPhongTro.aspx?Page={0}", page));
       }

       public static string ToDanhMucPhongTro()
       {
           return ToDanhMucPhongTro("1");
       }

       public static string ToTrangCaNhan(string id)
       {
           return BuildAbsolute(String.Format("TrangCaNhan.aspx?ID={0}", id));
       }
       public static string ToComment(string idphongtro, string page)
       {
           if (page == "1")
               return BuildAbsolute(String.Format("ChiTietPhongTro.aspx?IDPhongTro={0}", idphongtro));
           return BuildAbsolute(String.Format("ChiTietPhongTro.aspx?IDPhongTro={0}&Page={1}", idphongtro, page));
       }
       public static string ToComment(string idphongtro)
       {
           return ToComment(idphongtro, "1");
       }

       //admin phong tro

       public static string ToAdminPhongTro(string page)
       {
           if (page == "1")
               return BuildAbsolute(String.Format("Admin/PhongTro.aspx"));
           return BuildAbsolute(String.Format("Admin/PhongTro.aspx?Page={0}", page));
       }

       public static string ToAdminPhongTro()
       {
           return ToAdminPhongTro("1");
       }



       public static string ToAdminUpload(string clientId, string page)
       {
           if (page == "1")
               return BuildAbsolute(String.Format("Admin/Upload.aspx?id={0}", clientId));
           return BuildAbsolute(String.Format("Admin/Upload.aspx?id={0}&Page={1}", clientId, page));

       }
       public static string ToAdminUpload(string clientId)
       {
           return ToAdminUpload(clientId, "1");
       }
       public static string ToBaiViet(string id)
       {
           return BuildAbsolute(String.Format("ChiTietBaiViet.aspx?MaBaiViet={0}", id));
       }

       public static string ToDanhMucBaiBiet(string page)
       {
           if (page == "1")
               return BuildAbsolute("NoiDungBaiViet.aspx");
           else
               return BuildAbsolute(String.Format("NoiDungBaiViet.aspx?Page={0}", page));
       }

       public static string ToDanhMucBaiBiet()
       {
           return ToDanhMucBaiBiet("1");
       }
   }
}
